package top.buyibuyi.course.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.buyibuyi.course.R;
import top.buyibuyi.course.pojo.Course;
import top.buyibuyi.course.service.AddCourseService;

@RestController
@CrossOrigin
@RequestMapping("/course")
public class AddCoursecontroller {
    @Autowired
    private AddCourseService addCourseService;

    @PostMapping("/addCourse")
    public R addCounse(@RequestBody Course course){
        try {
            Boolean aBoolean = addCourseService.saveCourse(course);
            return R.ok().data("data",aBoolean);
        }catch (Exception e){
            e.printStackTrace();
            return R.error();
        }
    }
}
